package com.nintendo.frame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainFrame extends JFrame {

    public MainFrame() {
        setTitle("餐饮系统");
        setSize(800, 600);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        // 创建菜单栏
        JMenuBar menuBar = new JMenuBar();

        // 创建各个菜单
        JMenu systemManagementMenu = new JMenu("系统管理");
        JMenu tableManagementMenu = new JMenu("餐台管理");
        JMenu dishManagementMenu = new JMenu("菜品管理");
        JMenu businessManagementMenu = new JMenu("业务管理");
        JMenu checkoutManagementMenu = new JMenu("结账管理");
        JMenu helpMenu = new JMenu("帮助");

        // 添加菜单项（这里可以添加具体的动作监听器）
        JMenuItem systemSettingsItem = new JMenuItem("系统设置");
        JMenuItem userManagementItem = new JMenuItem("用户管理");
        JMenuItem CustomerManagementItem = new JMenuItem("用户管理");
        JMenuItem logManagementItem = new JMenuItem("日志管理");

        JMenuItem tableSetupItem = new JMenuItem("餐台设置");
        JMenuItem tableStatusItem = new JMenuItem("餐台状态");

        JMenuItem dishCategoryItem =  new JMenuItem("菜品分类");
        JMenuItem dishEditItem = new JMenuItem("编辑菜品");
        JMenuItem dishListItem =  new JMenuItem("菜品列表");
        JMenuItem dishOpen= new JMenuItem("点餐");

        JMenuItem orderManagementItem = new JMenuItem("订单管理");
        JMenuItem reservationManagementItem = new JMenuItem("预订管理");

        JMenuItem checkoutItem = new JMenuItem("结账");
        JMenuItem paymentHistoryItem = new JMenuItem("支付历史");

        JMenuItem helpItem = new JMenuItem("帮助文档");

        // 将菜单项添加到菜单
        systemManagementMenu.add(systemSettingsItem);
        systemManagementMenu.add(userManagementItem);
        systemManagementMenu.add(logManagementItem);
        systemManagementMenu.add(CustomerManagementItem);
        tableManagementMenu.add(tableSetupItem);
        tableManagementMenu.add(tableStatusItem);

        dishManagementMenu.add(dishCategoryItem);
        dishManagementMenu.add(dishEditItem);
        dishManagementMenu.add(dishOpen);
        dishManagementMenu.add(dishListItem);
        businessManagementMenu.add(orderManagementItem);
        businessManagementMenu.add(reservationManagementItem);

        checkoutManagementMenu.add(checkoutItem);
        checkoutManagementMenu.add(paymentHistoryItem);

        helpMenu.add(helpItem);

        // 为“餐台设置”菜单项添加动作监听器
        tableSetupItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new DeskFrame().setVisible(true);
            }
        });
        dishCategoryItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new CategoryFrame().setVisible(true);
            }
        });
        dishEditItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new DishFrame().setVisible(true);
            }
        });
        dishOpen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new DetailCustomerFrame().setVisible(true);
            }
        });
        checkoutItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new CheckOutFrame().setVisible(true);
            }
        });
        dishListItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new DishListFrame().setVisible(true);
            }
        });
        CustomerManagementItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new CustomerFrame().setVisible(true);
            }
        });
        // 将菜单添加到菜单栏
        menuBar.add(systemManagementMenu);
        menuBar.add(tableManagementMenu);
        menuBar.add(dishManagementMenu);
        menuBar.add(businessManagementMenu);
        menuBar.add(checkoutManagementMenu);
        menuBar.add(helpMenu);

        // 设置菜单栏
        setJMenuBar(menuBar);
        // 创建欢迎信息标签
        JLabel welcomeLabel = new JLabel("欢迎使用餐饮系统", SwingConstants.CENTER);
        welcomeLabel.setFont(new Font("Song", Font.BOLD, 36));
        // 创建内容面板并添加欢迎信息标签
        JPanel contentPanel = new JPanel(new BorderLayout());
        contentPanel.add(welcomeLabel, BorderLayout.NORTH);

        // 设置内容面板
        setContentPane(contentPanel);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
}
